use actix_web::web;
use crate::controllers::public::*;
use crate::controllers::admin::*;

pub fn configure_routes(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("/api")
            // Public routes (no authentication required)
            .service(
                web::scope("/public")
                    .configure(|cfg| {
                        cfg.service(get_articles)
                            .service(get_article)
                            .service(get_products)
                            .service(get_product)
                            .service(get_categories)
                            .service(get_brands)
                            .service(get_languages);
                    })
            )
            // Admin routes (authentication required)
            .service(
                web::scope("/admin")
                    .configure(|cfg| {
                        cfg.service(upload_resources)
                            .service(get_resource)
                            .service(delete_resource)
                            .service(assign_resource_to_article)
                            .service(remove_resource_from_article)
                            .service(get_article_resources)
                            .service(assign_resource_to_product)
                            .service(remove_resource_from_product)
                            .service(get_product_resources);
                    })
            )
    );
}